package com.example.demo;

import com.example.demo.cat.KafkaConsumerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.kafka.listener.KafkaMessageListenerContainer;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        System.out.println("DemoApplication");
        ApplicationContext context =  SpringApplication.run(DemoApplication.class, args);
        String[] names = context.getBeanDefinitionNames();
        for (int i = 0; i < names.length; i++) {
            System.out.println(names[i]);
        }

        KafkaConsumerFactory config = context.getBean(KafkaConsumerFactory.class);
        KafkaMessageListenerContainer listenerContainer = config.createListenerContainer("topic.group","topic.auto");
        listenerContainer.start();
    }

}